package Presentation.GraphicUI;

import Domain.Exceptions.UserNotLoggedInException;

import javax.swing.*;
import java.util.Map;

public class ListRecommendationsPanel extends MovieSystemPanel
{
    MutableList recList;

    public ListRecommendationsPanel(MainScreen mainScreen)
	{
		super(mainScreen);

        add(createInstructionLabel("Your personal recommended movies:"));

        recList = new MutableList();
        JScrollPane scrollPane = new JScrollPane(recList);

        add(scrollPane);
    }

    public void setUp(){
        recList.getContents().removeAllElements();
        Map<Double,String> list;
        try {
            list = m_controller.getRecommendation(0);
        } catch (UserNotLoggedInException e) {
            JOptionPane.showMessageDialog(m_mainScreen, e.getMessage());
            m_mainScreen.setActivePanel(MainScreen.MAIN_MENU);
            return;
        }
		
		 
         for(Map.Entry<Double,String> m : list.entrySet())
         {             
             recList.getContents().addElement(m.getValue()+" -  predicted rating: "+m.getKey());
         }        
    }
}
